package com.biz.primus.ms.search.transform;

import com.biz.primus.base.elasticsearch.entities.DepotEntity;
import com.biz.primus.model.depot.vo.DepotEsIndexVo;
import com.google.common.base.Function;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;

/**
 * 转化器(DepotEsIndexVo --> DepotEntity)
 *
 * @author david-liu
 * @date 2017年01月22日
 * @reviewer
 */
public class DepotEsIndexVo2DepotEntity implements Function<DepotEsIndexVo, DepotEntity> {
    @Override
    public DepotEntity apply(DepotEsIndexVo vo) {
        DepotEntity entity = new DepotEntity();
        entity.setId(vo.getId());
        entity.setDepotCode(vo.getDepotCode());
        entity.setName(vo.getName());
        entity.setAddress(vo.getAddress());
        entity.setProvinceId(vo.getProvinceId());
        entity.setCityId(vo.getCityId());
        entity.setDistrictId(vo.getDistrictId());
        entity.setDepotType(vo.getDepotType());
        GeoPoint geoPoint = new GeoPoint(vo.getDepotLatitude().doubleValue(), vo.getDepotLongitude().doubleValue());
        entity.setGeoPoint(geoPoint);
        entity.setBizStatus(vo.getBizStatus());
        return entity;
    }
}
